/**
 * This file is part of decent-cpp.
 *
 * decent-cpp is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * decent-cpp is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with decent-cpp.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once
#include <string>
#include "dcstdint.h"

/// Util functions
namespace dc {
/// Get decent API version
std::string const& version_api();
/// Get server impl version
std::string const& version_impl();

/// Milliseconds since Jan 1, 1970
u64_t timestamp();

/// Is a name valid according to API spec?
bool name_valid(std::string const& name);

#define DC_ERRORS                                                     \
  DC_ERROR(NOT_FOUND), DC_ERROR(NOT_YOURS), DC_ERROR(NOT_ALLOWED),    \
      DC_ERROR(NO), DC_ERROR(ALREADY_PERFORMED), DC_ERROR(FAILED),    \
      DC_ERROR(INCOMPLETE_PARAMETERS), DC_ERROR(REPEATED_PARAMETERS), \
      DC_ERROR(INVALID_PARAMETER_TYPE), DC_ERROR(INVALID_SESSION_ID), \
      DC_ERROR(INVALID_NAME), DC_ERROR(NAME_ALREADY_TAKEN),           \
      DC_ERROR(SHORT_PASSWORD), DC_ERROR(INCORRECT_PASSWORD)

/// Represents the errors our server can emit
enum class Error : size_t {
#define DC_ERROR(x) x
  DC_ERRORS,
#undef DC_ERROR
  SIZE
};

#ifndef DC_UTIL_EXPORT_ERRORS
#undef DC_ERRORS
#endif

/// Get string representation of error
std::string const& error_to_string(Error error);
}  // namespace dc